/*
 * Copyright 2013-2019 Xia Jun(3979434@qq.com).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ***************************************************************************************
 *                                                                                     *
 *                        Website : http://www.farsunset.com                           *
 *                                                                                     *
 ***************************************************************************************
 */
package com.workcell.workdata.im.model.request;

import com.workcell.workdata.im.annotation.CreateAction;
import com.workcell.workdata.im.annotation.validator.MomentImageFormat;
import com.workcell.workdata.im.annotation.validator.MomentVideoFormat;
import com.workcell.workdata.im.entity.Moment;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import java.io.Serializable;

@ApiModel
@MomentVideoFormat(message = "视频参数不完整",groups = CreateAction.class)
@MomentImageFormat(message = "图片参数不完整",groups = CreateAction.class)
public class MomentRequest implements Serializable {

	@Length(max = 1000,message = "text不能超过1000个字符",groups = CreateAction.class)
	@ApiModelProperty("文字内容")
	private String text;

	@Length(max = 2000,message = "content不能超过2000个字符",groups = CreateAction.class)
	@ApiModelProperty("主内容")
	private String content;

	@NotNull(message = "type不能为空",groups = CreateAction.class)
	@ApiModelProperty("类型")
	private Integer type;

	@Length(max = 1000,message = "extra不能超过1000个字符",groups = CreateAction.class)
	@ApiModelProperty("扩展信息")
	private String extra;

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public String getExtra() {
		return extra;
	}

	public void setExtra(String extra) {
		this.extra = extra;
	}

	public Moment ofMoment(){

		Moment moment = new Moment();
		moment.setContent(content);
		moment.setType(type.byteValue());
		moment.setText(text);
		moment.setExtra(extra);

		return moment;
	}
}
